package com.satan.vote.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName ResultVo
 * @Description TODO
 * @date 2022/3/28 18:49
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO<T> {

    private boolean success;

    private int code;

    private String msg;

    private T data;


    public static <T> ResultVO<T> success(T data) {
        return new ResultVO(true, 200,"success", data);
    }

    public static <T> ResultVO<T> fail(ResCode resCode) {
        return new ResultVO(false, resCode.getCode(), resCode.getMsg(), null);
    }
    // 静态方法，返回失败结果
    public static <T> ResultVO<T> fail(int code, String msg) {
        return new ResultVO(false,code, msg,null);
    }

}
